<?php
declare(strict_types=1);

namespace Dreamcat\ApiDocTest\TestCases;

use Dreamcat\ApiDoc\ApiDoc;
use Dreamcat\ApiDoc\ApiGenerators\ApiDocGenerator;
use Dreamcat\ApiDoc\ApiSaver\YapiSaver;
use Dreamcat\ApiDocTest\Demo\Route\RouteScan;
use GuzzleHttp\Client;
use PHPUnit\Framework\TestCase;

/**
 * Yapi真实的连接测试
 * @author vijay
 */
class YapiRealTest extends TestCase
{
    public function testNormal()
    {
        self::assertTrue(true);
        $file = __DIR__ . "/../../resources/yapi.json";
        if (!file_exists($file) || !is_readable($file)) {
            return;
        }
        $content = json_decode(file_get_contents($file), true);
        if (!isset($content["enable"]) || !$content["enable"]) {
            return;
        }
        $yapiSaver = new YapiSaver(
            $content["baseUrl"],
            $content["token"],
            new Client()
        );
        $api = new ApiDoc(new ApiDocGenerator(), new RouteScan(), $yapiSaver);
        $api->save("");
    }
}

# end of file
